<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/7
 * Time: 9:03
 */
include 'public.php';
$sql = "select * from table2";
$date = query($sql);

foreach ($date as $ig => $nb){
    $sql1 = "select username from table1 where t_id = ".$nb['put_user_id'];
    $dats = lin($sql1);
    $date[$ig]['name'] = $dats['username'];

    $sql2 = "select username from table1 where t_id = ".$nb['get_user_id'];
    $datc = lin($sql2);
    $date[$ig]['name1'] = $datc['username'];
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <h1>全部消息</h1>
    <div style="width: 359px;display: inline-block" class="lj">
        <?php foreach ($date as $k => $v){ ?>
            <?php if ($_SESSION['username'] == $v['name']){ ?>
                <div class="dj" style="box-shadow: 10px 10px 10px #ccc;height: 120px;">
                    <span>发送人：<?php echo $v['name'] ?></span>
                    <span>接收人：<?php echo $v['name1'] ?></span>
                    <span>时间：<?php echo date("Y-m-d H:i:s",$v['crete_time']); ?></span>
                    <span>内容:  <br> <?php echo $v['text']?></span>
                    <a href="message.php?p_id=<?php echo $v['p_id'] ?>">删除</a>
                </div>
                <a href="update.php?p_id=<?php echo $v['p_id'] ?>" class="lj">修改</a>
            <?php } ?>
        <?php } ?>
    </div>
</body>
</html>
